﻿using TrueSync;
using UnityEngine;

namespace HEFramework
{
    public static class SkillEffectItemDisappearComponentSystem
    {
        [EntitySystem]
        public class SkillEffectItemDisappearComponentAwakeSystem : AwakeSystem<SkillEffectItemDisappearComponent, FP>
        {
            protected override void Awake(SkillEffectItemDisappearComponent _self, FP _a)
            {
                _self.DisappearTime = Formula.TM(_a);
            }
        }


        [EntitySystem]
        public class SkillEffectItemDisappearComponentUpdateSystem : UpdateSystem<SkillEffectItemDisappearComponent>
        {
            protected override void Update(SkillEffectItemDisappearComponent _self)
            {
                if (_self.DisappearTime == -1)
                {
                    return;
                }

                FP deltaTime = Time.deltaTime;

                _self.DisappearTime -= deltaTime;
                if (_self.DisappearTime > 0)
                {
                    return;
                }

                _self.DisappearTime = 0;

                //结束父物体
                _self.Parent.Dispose();
            }
        }
    }
}